home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-06-26 | 2.0 KB | 54 lines | [TEXT/GEOL] |
- Item 6783579 8-May-89 11:37
-
- From: ALGER Alger, Jeff
-
- To: CH0095 CH DEV PEMD Group
-
- cc: MACAPP.TECH$ MACAPP Tech
-
- Sub: Response to Later Versions
-
- Ernie,
-
- Not to beat this horse to death, but there is another mechanism for handling
- changing versions of objects. If your GraphRecord corresponds to some object
- class TGraphObject, then you can use subclasses of TGraphObject to represent
- specific versions (this was pointed out by Chuck Lins in his response.)
-
- If you choose this architecture, the global function NewObjectByClassName and
- an IRes method in TGraphObject can combine to solve the problem. Place the
- subclass name in the data immediately preceeding the record itself. Assume
- that p is a pointer to the class name as read in to memory. Then the following
- code fragment gives the general idea:
-
- VAR
- myClassName: Str255;
- p: UNIV Ptr;
- myObject: TGraphObject;
- BEGIN
-
- myClassName := StringPtr(p)^;
- myObject := TGraphObject(NewObjectByClassName(myClassName));
- p := p + LENGTH(myClassName)+1;
- myObject.IRes(p);
-
-
- This is the way MacApp initializes views in 2.0, so it is not a "hokey" way of
- doing things. However, it does require the overhead of keeping class names in
- the data. And, of course, you must keep the old subclass names around.
- However, it does successfully isolate the knowledge of how to handle old
- versions of arbitrary classes to the subclasses themselves. To make this work,
- you should also have a WRes method to write out the data from the subclass.
-
- I use the names "IRes" and "WRes" because those are the names used by MacApp
- for views, which always initialize from resources. However, the same scheme
- works for other in-memory data structures and, with little modification, for
- reading the data from a data fork as requested.
-
- I do not know if this is applicable to your situation, but I thought it worth a
- mention.
-
- Jeff Alger
- Peat Marwick Main & Co.
-
-